#include "imageuploader.h"
#include <QFile>
#include <QDir>
#include <QFileInfo>

QString ImageUploader::saveImage(const QString &sourcePath, const QString &targetDir)
{
    QDir dir;
    if (!dir.exists(targetDir)) {
        dir.mkpath(targetDir);
    }

    QFileInfo fileInfo(sourcePath);
    QString targetPath = targetDir + "/" + fileInfo.fileName();
    if (QFile::copy(sourcePath, targetPath)) {
        return QDir::current().absoluteFilePath(targetPath);
    }

    return QString();
}
